<template>
  <Button :type="btnInfo.type" :size="size" v-bind="$attrs" v-on="$listeners">
    <Icon style="margin-right: 5px;" v-if="icon" :type="icon" />
    <slot v-else name="icon"></slot>
    <slot>{{ btnInfo.text }}</slot>
  </Button>
</template>

<script>
export default {
  props: {
    t: {
      type: String,
      default: 'cancel'
    },
    size: {
      type: String,
      default: 'default'
    },
    icon: {
      type: String,
      default: ''
    }
  },
  computed: {
    btnInfo() {
      const btns = {
        cancel: { type: 'default', text: '取消' },
        confirm: { type: 'primary', text: '确认' },
        del: { type: 'error', text: '删除' },
        save: { type: 'success', text: '保存' },
        info: { type: 'info', text: '' },
        text: { type: 'text', text: '' }
      }
      return btns[this.t]
    }
  },
  data() {
    return {}
  }
}
</script>
